package com.dsj.gxrd.modules.controller.activity;

import com.dsj.gxrd.modules.activity.domain.entity.RdScoreDetail;
import com.dsj.gxrd.modules.activity.domain.query.RdScoreDetailQuery;
import com.dsj.gxrd.modules.activity.domain.vo.RdScoreDetailInfoVo;
import com.dsj.gxrd.modules.activity.domain.vo.RdScoreDetailVo;
import com.dsj.gxrd.modules.activity.service.RdScoreDetailService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @author songpin566
 * @date 2023/09/14
 **/
@RestController
@Api("积分管理")
@RequestMapping("/score/detail")
public class RdScoreDetailController extends BaseController {

    @Autowired
    private RdScoreDetailService rdScoreDetailService;

    @RequiresPermissions("score:detail:list")
    @GetMapping("/list")
    public TableDataInfo list(RdScoreDetailQuery scoreDetailQuery) {
        startPage();
        List<RdScoreDetailVo> list = rdScoreDetailService.selectScoreDetailList(scoreDetailQuery);
        return getDataTable(list);
    }

    @RequiresPermissions("score:detail:query")
    @GetMapping("/{id}/{year}")
    public TableDataInfo getInfo(@PathVariable("id") Long id,@PathVariable("year") Integer year) {
        startPage();
        List<RdScoreDetailInfoVo> list = rdScoreDetailService.getInfo(id,year);
        return getDataTable(list);
    }

    @RequiresPermissions("score:detail:add")
    @PostMapping()
    public AjaxResult add(@RequestBody List<RdScoreDetail> scoreDetail) {
        return toAjax(rdScoreDetailService.insertOrUpdateScoreDetail(scoreDetail));
    }


}
